package lanqiao;
/**
 * @Project : AlgorithmLearning
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q2109.java
 * @Author : WangRuoyu
 * @Date : 2023/3/31 17:31
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q2109 {

    static int m;
    static int n;
    static long K;
    static long[][] s;
    static long res;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        m = Integer.parseInt(words[0]);
        n = Integer.parseInt(words[1]);
        K = Long.parseLong(words[2]);
        s = new long[m + 1][n + 1];
        for (int i = 1; i <= m; ++i) {
            words = br.readLine().split(" ");
            for (int j = 1; j <= n; ++j) {
                s[i][j] = Long.parseLong(words[j - 1]) + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
            }
        }

        for (int i = 1; i <= m; ++i) {
            for (int j = i; j <= m; ++j) {
                int l = 1;
                int r = 1;
                int sum = 0;
                for (; r <= n; ++r) {
                    sum += s[j][r] + s[i - 1][r - 1] - s[i - 1][r] - s[j][r - 1];
                    while (sum > K) {
                        sum -= s[j][l] + s[i - 1][l - 1] - s[i - 1][l] - s[j][l - 1];
                        l++;
                    }
                    res += r - l + 1;
                }
            }
        }

        System.out.println(res);
    }
}